package com.rfid.spec;

import com.rfid.transport.BufferPack;

import java.util.Vector;

public abstract class L0_APL {
    public Object m_reader = null;
    protected Vector<L0_PICC> m_piccList = new Vector();

    public abstract long GetId();

    public abstract String GetName();

    public abstract String GetDesc();

    public abstract int Inventory(byte paramByte, int paramInt, SpecAirProtocInvenParam paramSpecAirProtocInvenParam, SpecInvenParamSet paramSpecInvenParamSet);

    public void RegisterPicc(L0_PICC picc) {
        if (picc == null) return;
        for (int i = 0; i < this.m_piccList.size(); i++) {
            L0_PICC p = (L0_PICC) this.m_piccList.get(i);
            if (p != null && p.GetId() == picc.GetId()) return;
        }
        this.m_piccList.add(picc);
    }

    public L0_PICC GetPicc(long Id) {
        if (Id == 0L) {
            if (this.m_piccList.size() <= 0) return null;
            return (L0_PICC) this.m_piccList.get(0);
        }
        L0_PICC result = null;
        for (int j = 0; j < this.m_piccList.size(); j++) {
            L0_PICC p = (L0_PICC) this.m_piccList.get(j);
            if (p != null && p.GetId() == Id) {
                result = p;
                break;
            }
        }
        return result;
    }

    public L0_PICC GetPiccByHardId(long Id) {
        L0_PICC result = null;
        for (int j = 0; j < this.m_piccList.size(); j++) {
            L0_PICC p = (L0_PICC) this.m_piccList.get(j);
            if (p != null && p.GetHardId() == Id) {
                result = p;
                break;
            }
        }
        return result;
    }

    public void ReleaseRegisPicc() {
        this.m_piccList.clear();
    }

    public long IdentifyTag(L0_IdentifyData pIdfData) {
        int picc_type = 0;
        for (int j = 0; j < this.m_piccList.size(); j++) {
            L0_PICC picc = (L0_PICC) this.m_piccList.get(j);
            if (picc != null && picc.Identify(pIdfData)) {
                picc_type = (int) picc.GetId();
                break;
            }
        }
        return picc_type;
    }

    public int EncodeInvenParam(SpecAirProtocInvenParam pSpec, BufferPack binayData) {
        return -1;
    }

    public long GetHardId() {
        return 0L;
    }

    public TagDataReport DecodeInvenTagReport(long antID, long tagId, byte[] pReprtData, long dLen) {
        return null;
    }

    public TagDataReport DecodeInvenTagReport(BufferPack reportdata, long nSize) {
        return null;
    }

    public int Transceive(L0_PICC_HANDLE h, long accessCode, BufferPack parameters, BufferPack result) {
        return -7;
    }

    public int Transceive(L0_PICC_HANDLE hPICC, SpecTagTransc tagTransc) {
        return -7;
    }
}
